package world.liuru.poem.controller;

import org.springframework.web.bind.annotation.*;
import world.liuru.poem.entity.PoemExtendInfo;
import world.liuru.poem.service.PoemExtendService;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/poemExtend")
public class PoemExtendController {

    @Resource
    PoemExtendService poemExtendService;

    @PostMapping("")
    public PoemExtendInfo addPoemExtend(@RequestBody PoemExtendInfo poemExtendInfo){
        return poemExtendService.insertPoemExtend(poemExtendInfo);
    }

    @DeleteMapping("/{id}")
    public void deletePoemExtend(@PathVariable("id") String id){
        poemExtendService.deletePoemExtend(id);
    }

    @PutMapping("")
    public PoemExtendInfo updatePoemExtend(@RequestBody PoemExtendInfo poemExtendInfo){
        return poemExtendService.updatePoemExtend(poemExtendInfo);
    }

    @GetMapping("")
    public List<PoemExtendInfo> findAll(){
        return poemExtendService.findAllPoemExtend();
    }

    @GetMapping("/{id}")
    public PoemExtendInfo findById(@PathVariable("id") String id){
        return poemExtendService.findPoemExtendById(id);
    }

    @GetMapping("/byPoemId/{id}")
    public PoemExtendInfo findByPoemId(@PathVariable("id") String id){
        return poemExtendService.findPoemExtendByPoemId(id);
    }

}
